package com.example.liangwenli;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.Callback;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

public class MainActivity extends AppCompatActivity {

    private EditText et_city;
    private TextView tv_query;
    private TextView tv_result;
    private Button btn_page1;
    private Button btn_page2;
    private Button btn_page3;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //实例化控件
        et_city=findViewById(R.id.et_city);
        tv_query=findViewById(R.id.tv_query);
        tv_result=findViewById(R.id.tv_result);
        btn_page1=findViewById(R.id.btn_page1);
        btn_page2=findViewById(R.id.btn_page2);
        btn_page3=findViewById(R.id.btn_page3);
        //初始化数据
        StringBuilder stringBuilder=new StringBuilder();
        stringBuilder.append("默认天气信息\n\n");
        stringBuilder.append("城市 : 崇左(chongzuo)\n");
        stringBuilder.append("天气 : 25℃~32℃，多云\n");
        stringBuilder.append("风向 : 东南风，1级，1km/h\n");
        stringBuilder.append("空气 : 良，PM2.5值为55\n");
        stringBuilder.append("提示 : 空气好，可以外出活动，除极少数对污染物特别敏感的人群以外，对公众没有危害!\n");
        tv_result.setText(stringBuilder.toString());
        //初始化事件
        btn_page1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this,"当前为界面1喔!",Toast.LENGTH_SHORT).show();
            }
        });
        btn_page2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //进入界面2
                startActivity(new Intent(MainActivity.this,SecondActivity.class));
                //关闭当前界面
                finish();
            }
        });
        btn_page3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //进入界面3
                startActivity(new Intent(MainActivity.this,ThirdActivity.class));
                //关闭当前界面
                finish();
            }
        });
    }

}
